-- Viral Resistance - T-Engine 4 Module
-- Copyright (C) 2010 Mikolai Fajer
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
--
-- Mikolai Fajer "yufra"
-- mfajer@gmail.com

newChat{ id="welcome",
	text = [[#WHITE#"Decontamination completed.  The Chief of Medicine has been contacted and is en route.  Remain in place for debriefing."
#LIGHT_GREEN#The gas begins to clear from the Biohazard Ward to reveal a scene of carnage.  The normally ordered ward has papers strewn all over the floor, covered here and there by lifeless bodies.  Even in death the faces of those infected is twisted in rage.]],
	answers = {
		{"#LIGHT_BLUE#Turn around.", jump="outside",
			action=function(npc, player)
				-- Chief of Medicine arrives
				local start
				for i, v in pairs(game.level.spots) do
					if v.type == "quests" and v.subtype == "chief of medicine" then
						start = v
						break
					end
				end
				npc:move(start.x, start.y, true)
				-- Populate people watching
				local tg = {type="ball", radius=5, stop_block=true}
				player:project(tg, start.x, start.y, function(tx, ty)
					if rng.percent(25) and not game.level.map:checkAllEntities(tx, ty, "block_move") then
						local e = game.zone:makeEntity(game.level, "actor", {type="human"})
						e:resolve()
						e:resolve(nil, true)
						game.zone:addEntity(game.level, e, "actor", tx, ty)
					end
				end)
			end,
		},
	}
}

newChat{ id="outside",
	text = [[#LIGHT_GREEN#Through the windows to the rest of the hospital you can see people gathering around, peering back at you and talking to each other.  After a few minutes a contingent of men approach from the direction of the elevator, led by the Chief of Medicine.  He walks up to the outside of the door and hits the intercom button.
#WHITE#"What is your name and rank?"]],
	answers = {
		{([["Corporal %s, sir!"]]):format(game.player.name), jump="why"}
	}
}

newChat{ id="why",
	text = [[#WHITE#"Why was the lockdown initiated?"]],
	answers = {
		{[["The Chief of Virology ordered it, sir.  The patient in room 6 became violent, followed by the rest of the patients in the ward."]], jump="who"}
	}
}

newChat{ id="who",
	text = [[#LIGHT_GREEN#The chief's expression pales as you tell him what happened.  He takes a moment to collect himself and then asks #WHITE#"Did you activate the lockdown Corporal?"]],
	answers = {
		{[["Yes, sir!"]], jump="reward", cond = function(npc, player)
			return player:isQuestStatus("code_green", engine.Quest.COMPLETED, "lockdown")
		end,
		action = function(npc, player)
			player.unused_generics = player.unused_generics + 1
		end},
		{[["No, sir.  The remote system activated the lockdown and I merely escaped."]], jump="noreward", cond = function(npc, player)
			return not player:isQuestStatus("code_green", engine.Quest.COMPLETED, "lockdown")
		end}
	}
}

newChat{ id="reward",
	text = [[#WHITE#"You did well Corporal, you are an example of excellence."
#LIGHT_BLUE# You receive a bonus generic talent point.]],
	answers = {
		{[["Thank you, sir!"]], jump="quarantine"}
	}
}

newChat{ id="noreward",
	text = [[#WHITE#"Well it is a good thing you did, otherwise it would take valuable time before we knew what happened."]],
	answers = {
		{"#LIGHT_BLUE#Continue", jump="quarantine"}
	}
}

newChat{ id="quarantine",
	text = [[#LIGHT_GREEN#The chief of medicine releases the intercom button and turns to one of the men accomapnying him.  After a few moments of conversation this man begins herding the people who had gathered around in the hallway away from the Biohazard Ward.
#WHITE#"Corporal @playername@, we will have to keep you in quarantine until we determine the threat.  A Hazmat team will be arriving shortly to take samples and take them to the lab on the third floor.  Only after those samples have been analyzed will we know what we are dealing with and how to proceed.  It should be safe for you to return to the Biohazard Ward so that we can clear the airlock for the Hazmat team.  Do you understand?"]],
	answers = {
		{[["Yes, sir!"]], jump="clear"}
	}
}

newChat{ id="clear",
	text = [[#WHITE#"Very good, return to the Biohazard Ward and await further orders."
#LIGHT_GREEN#The chief of medicine punches a few buttons on the intercom keypad and the inner ward doors open.]],
	answers = {
		{"#LIGHT_BLUE#Continue.", action=function(npc, player)
			player:hasQuest("code_green"):unlock_inner_ward()
			-- Set up the lose of power and mayhem!
			player:newEffect{name="MAYHEM_COUNTDOWN", desc=[[]], type="countdown",
				on_lose = function(self, err)
					player:grantQuest("power_loss")
					player:hasQuest("power_loss"):setup(npc)
					player:setQuestStatus("power_loss", engine.Quest.PENDING, "investigate")
				end
			}
			player:setEffect(player.EFF_MAYHEM_COUNTDOWN, 5, {})
		end}
	}
}

return "welcome"